<?php 
require 'Model.php';
class ListModel extends Model{
	function __construct(){
		parent::__construct();
		//$this->mod = 'carbrand';
	}
		function redirect($url, $msg)
{	  
   echo $msg.'<a href="'.$url.'">如果没有跳转，请点这里跳转</a>';
   header("refresh:3;url=$url"); 
}







	function getct(){
		$sql="select * from cartype";
		$data= $this->conn->query($sql);
		return $data;
	}

	function getCbl($id,$data){

		$list=array();
		foreach ($data as $key ) {
			
			$sql="select * from carphoto left join cartype on carphoto.tid=cartype.tid left join carbrand on carphoto.bid=carbrand.bid  where carphoto.bid=".$id." and carphoto.tid=".$key['tid'];
			//var_dump($sql);

			$li= $this->conn->query($sql);
			//$li['typename']=$key['cartypename'];
			$list[]=$li;
		}

		return $list;
	} 
		function getbt(){
		$sql="select * from carbrand";
		$data= $this->conn->query($sql);
		return $data;
	}

function getct1(){
		$sql="select * from carbrand";
		$data= $this->conn->query($sql);
		return $data;
	}




	function getCbl1($id,$data){

		$list=array();
		foreach ($data as $key ) {
			
			$sql="select * from carphoto left join cartype on carphoto.tid=cartype.tid left join carbrand on carphoto.bid=carbrand.bid  where carphoto.bid=".$key['bid']." and carphoto.tid=".$id;
			//var_dump($sql);

			$li= $this->conn->query($sql);
			//$li['typename']=$key['cartypename'];
			$list[]=$li;
		}

		return $list;
	} 




function getshow($id){

		
			
			$sql="select * from carphoto left join cartype on carphoto.tid=cartype.tid left join carbrand on carphoto.bid=carbrand.bid  where cid=".$id;


			$li= $this->conn->query($sql);
		
	

		return $li;
	} 


































	function getCartypeList(){
		$sql_ct="select * from cartype";
		$ct_list = $this->conn->query($sql_ct);
		
		$c_list=array();
		foreach($ct_list as $one){
		    $sql="select * from cartype where tid=".$one['tid']." order by id  limit 0,4 ";
		   
		    $clist=array();
		    $clist['cartypename']=$one['cartypename'];
		    $clist['tid']=$one['tid'];
		    $clist['list']=$this->conn->query($sql);
		    $c_list[]=$clist;
		}
		    return $c_list;
	}

	function getCarphotoList(){
		$sql_cp="select * from carphoto";
		$cp_list = $this->conn->query($sql_cp);
		
		$c_list=array();
		foreach($cp_list as $one){
		    $sql="select * from carphoto where cid=".$one['cid']." order by id  limit 0,4 ";
		   
		    $clist=array();
		    $clist['carname']=$one['carname'];
		    //$clist['bid']=$one['bid'];
		    //$clist['tid']=$one['tid'];
		    $clist['cid']=$one['cid'];
		    $clist['list']=$this->conn->query($sql);
		    $c_list[]=$clist;
		}
		    return $c_list;
	}
	function getCarbrandList(){
		$sql_cb="select * from carbrand";
		$cb_list = $this->conn->query($sql_cb);
		
		$c_list=array();
		foreach($cb_list as $one){
		    $sql="select * from carbrand where bid=".$one['bid']." order by id  limit 0,4 ";
		   
		    $clist=array();
		    $clist['carbrandname']=$one['carbrandname'];
		    $clist['bid']=$one['bid'];
		    $clist['list']=$this->conn->query($sql);
		    $c_list[]=$clist;
		}
		    return $c_list;
	}

	function getCartypeById($id){
		$sql="select * from cartype where tid=".$id;
	    $data = $this->conn->query($sql);
		return $data;

}
}
?>